<%@page import="com.railway.news.model.*"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<html>

	<head> 
	     <%@ include file="/commons/commoncssjs.jsp" %>
		<link rel="stylesheet" href="${ctx}/css/ztree.css" type="text/css">
		<link rel="stylesheet" href="${ctx}/css/zTreeStyle/zTreeStyle.css"type="text/css">
		<script type="text/javascript"	src="${ctx}/scripts/jquery.ztree.core-3.0.min.js"></script>
		<script type="text/javascript"	src="${ctx}/scripts/jquery.ztree.excheck-3.0.min.js"></script>

		<script type="text/javascript"> 
		   function openDeptUserList(type){ 
		      	          
	        var width = 800;
            var height =350;
            var url='${ctx}/system/SysUser/showDeptUserList.do'; //要打开的窗口   
            var returnVal =  window.showModalDialog(url, window.document, "dialogWidth="+width+"px;dialogHeight="+height+"px;status:0;scroll:no");   
            if(returnVal == undefined) {           
          	   return;           
            }
   
            if(type == 'maintainer'){
              form1.maintainerid.value = returnVal[0];
               form1.maintainer.value = returnVal[1];
            }else if(type == 'checker'){
                      form1.checker.value = returnVal[0];
               form1.checker.value = returnVal[1];
            }else if(type =='visitor'){
                      form1.visitor.value = returnVal[0];
               form1.visitor.value = returnVal[1];
           
            }
             
 		  }
	    function openURL(urlstr,width,height){  
      	var url ;
      	if('NewsCategory' == urlstr){
       	  url = '${ctx}/news/Category/showCategoryTree.do';      
      	}
        
           var returnVal = window.showModalDialog(url, window, "dialogWidth="+width+"px;dialogHeight="+height+"px;status:0;scroll:no");   
           form1.parentId.value = returnVal[0]; 
     
        }  
	    var setting = {
			check: {
				enable: true,
				chkboxType: { "Y" : "ps", "N" : "ps" }
			},
			view: {
				dblClickExpand: false
			},
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				beforeClick: beforeClick,
				onCheck: onCheck
			}
		};

		function beforeClick(treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo");
			zTree.checkNode(treeNode, !treeNode.checked, null, true);
			return false;
		}
		
		function onCheck(e, treeId, treeNode) {

			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			nodes = zTree.getCheckedNodes(true),
			v = "";
	
			for (var i=0, l=nodes.length; i<l; i++) {
				if(nodes[i].type == 1){
				var tt = nodes[i].id;
		     	form1.permituids.value +=   tt.substring(1,tt.length) + ",";
				v += nodes[i].name + ",";}
			}
			if (v.length > 0 ) v = v.substring(0, v.length-1);
			var cityObj = $("#citySel");
			cityObj.attr("value", v);
		}

		 function showMenu() {
			var cityObj = $("#citySel");
			
			var cityOffset = $("#citySel").offset();
			
			$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

			$("body").bind("mousedown", onBodyDown);
		}
		function hideMenu() {
			$("#menuContent").fadeOut("fast");
			$("body").unbind("mousedown", onBodyDown);
		}
		function onBodyDown(event){
			if (!(event.target.id == "menuBtn" || event.target.id == "citySel" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
				hideMenu();
			}
		}
	    $(document).ready(function() {        	        
	           $.get("${ctx}/system/SysUser/getUserDept.do", {	            
                Action:"get",Name:"user01"}, function (data, textStatus){		
                var zNodes = eval(data);              
                $.fn.zTree.init($("#treeDemo"), setting, zNodes);                
				});					
	    }); 
	    </script>



		<title><%=CategoryColums.TABLE_ALIAS%>新增</title>
	</head>
	<body>
		<form id="form1" action="${ctx}/news/Category/save.do" method="post">
			<input type="submit" value="提交" />
			<input type="button" value="返回列表"
				onclick="window.location='${ctx}/news/Category/list.do'" />
			<input type="button" value="后退" onclick="history.back();" />
			<input type="hidden" id="permituids" name="permituids"
				value="${model.permituids}" />
			<table class="formTable">
				<input type="hidden" id="id" name="id" value="${model.id}" />
				<!-- ONGL access static field: @package.class@field or @vs@field -->
				<!--tr>
					<td class="tdLabel">
						<%=CategoryColums.ALIAS_PARENT_ID%>:
					</td>
					<td>
						<input id="parentId" name="parentId" value="${model.parentId}"
						 onclick="javascript:openURL('NewsCategory',250,400)"	type="text" class="easyui-validatebox" />
					</td>
				</tr-->
				<!--<tr>
					<td class="tdLabel">
						<%=CategoryColums.ALIAS_SID%>:
					</td>
					<td>
						<input id="sid" name="sid" value="${model.sid}" type="text"
							class="easyui-validatebox" />
					</td>
				</tr>


				--><tr>
					<td class="tdLabel">
						<%=CategoryColums.ALIAS_NAMES%>:
					</td>
					<td>
						<input id="names" name="names" value="${model.names}" type="text"
							class="easyui-validatebox" />
							
					</td>
				</tr>

				<!--<tr>
					<td class="tdLabel">
						<%=CategoryColums.ALIAS_DESCS%>:
					</td>
					<td>
						<input id="descs" name="descs" value="${model.descs}" type="text"
							class="easyui-validatebox" />
					</td>
				</tr>


				--><tr>
					<td class="tdLabel">
						<%=CategoryColums.ALIAS_ORDER_NO%>:
					</td>
					<td>
						<input id="orderNo" name="orderNo" value="${model.orderNo}"
							type="text" class="easyui-validatebox" />
					</td>
				</tr><!--


				<tr>
					<td class="tdLabel">
						<%=CategoryColums.ALIAS_STATE%>:
					</td>
					<td>
						<input id="state" name="state" value="${model.state}" type="text"
							class="easyui-validatebox" />
					</td>
				</tr>


				--><tr>
					<td class="tdLabel">
						<%=CategoryColums.ALIAS_CA_TYPES%>:
					</td>
					<td>
					    <select id="caTypes" name="caTypes" >
						   <option  value="TXT">文字</option>
						   <option  value="IMG">图片</option> 
						</select>
						<input id="caTypes" name="caTypes" value="${model.caTypes}"
							type="text" class="easyui-validatebox" />
					</td>
				</tr>
			   <tr>
				    <td class="tdLabel">维护负责人</td>		
					<td>
						<input readonly value="" id="maintainer" name=""maintainer" maxlength="200"  class="" onclick="javascript:openDeptUserList('maintainer');"/>
						<input type="hidden" name ="maintainerid"/>
					</td>
	     		</tr> 
				<tr>
					<td class="tdLabel">
						<%=CategoryColums.ALIAS_PUBLIC_TYPE%>:
					</td>
					<td>
					   <select id="publicType" name="isCheck" >
					       <option  value="Y">是</option> 
						   <option  value="N">否</option>
						   
						</select>
					 </td>
				</tr>
				<tr>
		     		<td class="tdLabel">可访问人</td>		
						<td>
							<input value="" onclick="javascript:openDeptUserList('visitor');" id="visitor" name="visitor" maxlength="200"  class=""/>
							<input type="hidden" name ="visitorid"/>
					</td>
				</tr>
			  
	     		<tr>
					<td class="tdLabel">
						<%=CategoryColums.ALIAS_IS_CHECK%>:
					</td>
					<td>
					   <select id="isCheck" name="isCheck" >
						   <option  value="N">否</option>
						   <option  value="Y">是</option> 
						</select>
						 ${model.isCheck}" 
					</td>
				</tr>
				<tr>
		     		<td class="tdLabel">审核人</td>		
						<td>
							<input value="" id="checker" name="checker" maxlength="200"  onclick="javascript:openDeptUserList('checker');" />
							<input type="hidden" name ="checkerid"/>
					</td>
				</tr>
				<!--<tr>
					<td class="tdLabel">
						<%=CategoryColums.ALIAS_CREATOR%>:
					</td>
					<td>
						<input id="creator" name="creator" value="${model.creator}"
							type="text" class="easyui-validatebox" />
					</td>
				</tr>
				<tr>
					<td class="tdLabel">
						<%=CategoryColums.ALIAS_CREATE_TIME%>:
					</td>
					<td>
						<input value="${model.createTimeString}" id="createTimeString"
							name="createTimeString" type="text" class="easyui-datebox" />
					</td>
				</tr>
			--></table>
		</form>

	</body>
	<script>
//begin $(document).ready(handler)
$(function(){
$('#form1').submit(function(){
	//return $('#form1').form('validate');
});}
);//end $(document).ready(handler)
</script>
</html>

